Skip to content

feat(core): Claude Code lessons — instruction file exclusion + explicit dangerous preset - #186

Open
raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/claude-code-lessons
Open

feat(core): Claude Code lessons — instruction file exclusion + explicit dangerous preset#186
raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/claude-code-lessons

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

借鉴 Claude Code 两处机制落地 (2026-08-19)

1. core/harness/memory.py — 指令文件排除模式

  • 新增 DEEPCODE_INSTRUCTION_EXCLUDES 环境变量: 逗号分隔 glob 模式 (如 **/code/CLAUDE.md,**/vendor/**)
  • 命中的 AGENTS.md/DEEPCODE.md/CLAUDE.md 跳过注入 — 避免 monorepo 子目录/第三方代码的指令污染主提示词
  • 自实现 glob→regex: ** 匹配任意层级 (可选前缀 (?:.*/)?), */? 不跨路径分隔符; 前缀同名目录 (vendorized ≠ vendor/) 不误匹配
  • 非法 glob 模式被忽略, 不阻断加载

2. core/domain/execution_security.py — 显式危险预设

  • 新增 ExecutionAccessPreset.DANGEROUS_SKIP = "dangerous_skip", 对齐 Claude Code --allow-dangerously-skip-permissions
  • 与 FULL_ACCESS 同强度 (FULL_AUTO/无沙箱/unrestricted/never) 但名字自带危险警示, 供日志/UI 明确区分

3. tests/test_memory.py — 4 个新用例

  • glob 正反例 (含 vendorized 反例) / project_instructions 集成 / 非法模式容错

验证

  • tests/test_memory.py: 20/20 通过
  • tests/domain/test_execution_security.py + test_execution_security_policy.py: 19/19 通过

…it dangerous preset

借鉴 Claude Code 两处机制 (2026-08-19):

1. core/harness/memory.py — 指令文件排除模式
   - DEEPCODE_INSTRUCTION_EXCLUDES env: 逗号分隔 glob (如 **/code/CLAUDE.md,**/vendor/**)
   - 命中的 AGENTS.md/DEEPCODE.md/CLAUDE.md 跳过注入, 避免 monorepo 子目录/
     第三方代码指令污染主提示词
   - 自实现 glob→regex: ** 匹配任意层级(可选前缀 (?:.*/)?), * / ? 不跨路径
     分隔符; vendorized ≠ vendor/ 前缀同名不误匹配
   - 非法模式忽略不阻断加载

2. core/domain/execution_security.py — 显式危险预设
   - ExecutionAccessPreset.DANGEROUS_SKIP="dangerous_skip", 对齐 Claude Code
     --allow-dangerously-skip-permissions; 与 FULL_ACCESS 同强度但名字自带
     危险警示, 供日志/UI 明确区分

3. tests/test_memory.py — 4 个新用例 (glob 正反例/集成/非法模式)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant